
/* GCSx
** EVENT.H
**
** Our custom event queue to allow preempting SDL's event queue
*/

/*****************************************************************************
** Copyright (C) 2003-2006 Janson
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
*****************************************************************************/

#ifndef __GCSx_EVENT_H_
#define __GCSx_EVENT_H_

// Add event to queue; will occur before any SDL events
void insertEvent(const SDL_Event* customEvent);

// Add event to beginning of queue; intended for SDL_CLOSE events
void preemptEvent(const SDL_Event* customEvent);

/* SDL_OBJECTCHANGE events no longer use the queue
**
// Search for matching event to combine, add to beginning of queue if not found
// Intended for SDL_OBJECTCHANGE events
void combinatoryEvent(const SDL_Event* customEvent);
**
*/

// Returns true if any events are waiting in OUR queue only
int eventsWaiting();

// Returns the next event from our queue or SDL's queue
// Returns 1 if event was found, 0 if none waiting
int grabEvent(SDL_Event* store);

// Removes all events from our queue that reference the
// given window
void cleanEvents(const void* window);

// Clears internal event queues, freeing SDL_OBJECTCHANGE objects
// Basically CLOSE, FOCUS, and OBJCHANGE
// Call when you reset the desktop/quit (memory cleanup)
// Use desktop->initEventCleanup() to clear user-initiated events
void clearEvents();

// Push an unused event (or a copy of mouse events) to game queue
// or retrieve the next game queue event
// Used only in desktop overlay mode- otherwise game just
// calls grabEvent
void storeEventGame(const SDL_Event* event);
int grabEventGame(SDL_Event* store);

#endif
